home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
- <stack>
- <name>in</name>
- <id>-1</id>
- <cardCount>15</cardCount>
- <cardID>2424</cardID>
- <listID>8649</listID>
- <cantModify><false /></cantModify>
- <cantDelete><true /></cantDelete>
- <cantAbort><false /></cantAbort>
- <cardSize>
- <width>512</width>
- <height>342</height>
- </cardSize>
- <script>--…………………………………………………………………………………………………………………………………………………………………………………………
- --
- -- Sound Scripter copyright 1988 by Tim Lyons
- --
- -- Please feel free to use and modify this stack as you see fit but
- -- leave this notice in place. If you make changes and redistribute the
- -- altered version, then note which changes are your contribution, so
- -- that the user knows to whom to complain about which feature.
- -- I am not asking for money, and you may not charge others for my
- -- work. If you find this stack useful, then drop me a line. Pass along
- -- any complaints, suggestions, clever tricks, or improvements you have
- -- made to my code.
- -- Tim Lyons
- -- 9211 Palmer rd.
- -- North East, PA 16429
- --
- --…………………………………………………………………………………………………………………………………………………………………………………………
- --
- --
- --
- -- This is my first major stack created from scratch. I started
- -- writing it as an exercise to teach myself HyperTalk while I was
- -- reading Danny Goodman’s book. I had enough fun with it that I kept
- -- working on it while I read the draft version of HyperCard Script
- -- Language Guide.
- -- It may not show now, but at one time, this script was fairly
- -- straightforward; however, as I added frills and error checking,
- -- things got out of control. Parts of this script date back to my
- -- earliest efforts. As I became more familiar with how things worked,
- -- I backed up and reworked much, but not all, of the earlier sections.
- -- Unfortunately, it has become so complex that I’m reluctant to monkey
- -- around with things that are working. I hope that it won’t be too
- -- confusing to be useful.
- --
- --
- --…………………………………………………………………………………………………………………………………………………………………………………………
-
- on openStack
- global stackName
- put the name of this stack into stackName
- startingUp
- end openStack
-
- on resume
- startingUp
- send "startUp" to card "piano keyboard"
- end resume
-
- on startingUp
- global voice,theTempo,duration,durationButton,scriptMode
- global menu1,menu2,rebuildPopUpMenu
- global modifierButton,tripletCount,priorUserLevel,startingUserLevel
- push recent card
- get the userlevel
- put it into startingUserLevel
- set the userlevel to 5
- if the version ‚â• 1.1 then set textArrows to true
- set the rect of card field "welcomeField"¬
- of card "piano keyboard" to 3,23,509,128
- set the visible of card field "welcomeField"¬
- of card "piano keyboard" to true
- setDefaultValues
- put true into rebuildPopUpMenu
- put "Harpsichord" into voice
- put 100 into theTempo
- put "w" into duration
- put "whole" into durationButton
- set the lockscreen to true
- buildGoToFileMenu
- go to card "piano keyboard"
- end startingUp
-
-
- on setDefaultValues
- global modifierButton,tripletCount,scriptMode
- global copyPromptCount,firstCopyCardPrompt
- set the visible of card button "Sound Scripter" ¬
- of card "helpCard7" to false
- put true into firstCopyCardPrompt
- put 0 into copyPromptCount
- put "none" into modifierButton
- put 0 into tripletCount
- put "newLine" into scriptMode
- end setDefaultValues
-
- on closeStack
- shuttingDown
- end closeStack
-
- on suspend
- shuttingDown
- end suspend
-
- on shuttingDown
- global menu1,menu2
- global priorUserLevel,startingUserLevel
- global durationButton,modifierButton
- deleteMyMenus
- get the userLevel
- put it into priorUserLevel
- set the userLevel to 5
- get the freeSize of this stack
- if it > 1024 * 2 then doMenu "Compact Stack"
- set the userLevel to priorUserLevel
- set the userlevel to startingUserLevel
- set the hilite of card button durationButton ¬
- of card "piano keyboard" to false
- set the hilite of card button modifierButton ¬
- of card "piano keyboard" to false
- put empty into card field "tempoField" of card "piano keyboard"
- put empty into bkgnd field "noteFeedback" of card "piano keyboard"
- put empty into card field "changeVoiceField" of card "piano keyboard"
- end shuttingDown
-
- on buildMyMenus
- global menu1,menu2
- set the lockScreen to true
- put NewMenu("Script","Play this script/[","Play selection",¬
- "Play last line/]","Stop playing/.","(-","Save to file…/S",¬
- "New script…/A","Erase this script/E","(-","Chromatic Scale…",¬
- "(-","Start New Line/\",¬
- "Insert Empty Line/L","Erase Last Line/D") into menu1
- if menu1 is 0 then answer("Unable to make menu 'Script'") with "Drat"
- send upDateMenu to card field "buildGTFMenuField"¬
- of card "piano keyboard"
- if menu2 is 0 then answer("Unable to make menu 'Go To File'") with "Drat"
- end buildMyMenus
-
- on deleteMyMenus
- global menu1,menu2
- set the lockScreen to true
- put DeleteMenu(menu1) into menu1 -- clearing global for safety
- put DeleteMenu(menu2) into menu2
- end deleteMyMenus
-
-
- on buildGoToFileMenu
- global cardCount
- put "on upDateMenu"&return into temp
- put "global menu2"&return after temp
- put "put NewMenu(""e&"Go To File""e after temp
- put cardsInBkgnd("SavedScriptsBkgnd") into cardCount
- if cardCount > 16 then put 16 into cardCount
- repeat with i = 1 to cardCount - 1
- get the short name of card i + 1 of bkgnd "SavedScriptsBkgnd"
- put ",""e&it"e after temp
- end repeat
- put ") into menu2"&return&"end upDateMenu" after temp
- set the script of card field "buildGTFMenuField" ¬
- of card "piano keyboard" to temp
- end buildGoToFileMenu
-
-
- function cardsInBkgnd bkgndName -- There’s probably a simpler way to do
- -- this, but I didn’t think of it, so
- -- the script ends up running around
- -- in circles while building the
- -- "Go To File" menu. I don’t like the
- -- idea, but I don’t know how else to
- -- find out the names of all the cards
- -- of a specific background. Anybody out
- -- there know a better way?
- global menu1,menu2
- hide the message box
- put 0 into theCount
- set the lockscreen to true
- get the short name of first card of bkgnd bkgndName
- put it into name1
- go to card name1
- put empty into cardName
- repeat until cardName = name1
- go to next card of bkgnd bkgndName
- get the short name of this card
- put it into cardName
- add 1 to theCount
- end repeat
- set the lockscreen to false
- return theCount
- end cardsInBkgnd
-
- on idle
- global menu1,menu2,lastTick
- if (the ticks-lastTick)>120 then
- put the ticks into lastTick
- ShowMenu(menu1)
- ShowMenu(menu2)
- end if
- pass idle
- end idle
-
- on doMenu which
- global menu1,menu2,answer
- global scriptMode,voice,firstCopyCardPrompt
- global modifier,modifierButton,note,duration
- global whichNote,firstNote,secondNote,scale
- if which is "Play this script" then
- send playScript to card "piano keyboard"
- exit doMenu
- else if which is "Play selection" then
- send playSelection to card "piano keyboard"
- exit doMenu
- else if which is "Play last line" then
- send playLine to card "piano keyboard"
- exit doMenu
- else if which is "Stop playing" then
- play stop
- exit doMenu
- else if which is "New script…" then
- answer "Save to file before erasing current script?" with¬
- "Erase" or "Cancel" or "Save"
- if it is "Cancel" then exit doMenu
- if it is "Save" then
- send saveScript to card "piano keyboard"
- go to card "piano keyboard"
- end if
- put empty into card field "ScriptWindow"
- exit doMenu
- else if which is "Erase this script" then
- put empty into card field "ScriptWindow"
- exit doMenu
- else if which is "Save to file…" then
- send saveScript to card "piano keyboard"
- if answer <> "Oops" then buildGoToFileMenu
- go to card "piano keyboard"
- exit doMenu
- else if which is "Chromatic Scale…" then
- put "The first note is" into whichNote
- put "Select the first note for the scale." into ¬
- line 2 of card field "headerPrompt"
- set the visible of card field "headerPrompt" to true
- findNote
- if note <> "Not a note button" then
- put note into firstNote
- else
- set the visible of card field "headerPrompt" to false
- exit doMenu
- end if
- put "The last note is" into whichNote
- put "Select the last note for the scale." into ¬
- line 2 of card field "headerPrompt"
- findNote
- if note <> "Not a note button" then
- put note into secondNote
- else
- set the visible of card field "headerPrompt" to false
- exit doMenu
- end if
- put "Scale under construction." into line 2 of card field "headerPrompt"
- if secondNote > firstNote then
- upScale
- else
- downScale
- end if
- put quote after scale
- do scale
- put empty into card field "headerPrompt"
- set the visible of card field "headerPrompt" to false
- exit doMenu
- else if which is "Start New Line" then
- put "newLine" into scriptMode
- exit doMenu
- else if which is "Insert Empty Line" then
- put "--"&return after card field "scriptWindow"
- put "newLine" into scriptMode
- exit doMenu
- else if which is "Erase Last Line" then
- delete last line of card field "scriptWindow"
- put "newLine" into scriptMode
- exit doMenu
- end if -- end menu1 handler
- -- menu2 go to saved file
- global cardCount,stackName
- if the name of this stack is stackName then
- repeat with i = 1 to cardCount - 1
- get the short name of card i + 1 of bkgnd "SavedScriptsBkgnd"
- if which = it then
- send enableMenusFalse to card "piano keyboard"
- go to card it
- exit doMenu
- end if
- end repeat -- end menu2 handler
- end if
-
- if which is "Paste Card" then
- if firstCopyCardPrompt = true or firstCopyCardPrompt = empty then
- beep
- answer "Duplicate card names might cause crashes!!"¬
- with "That’s OK" or "Cancel"
- if it is "Cancel" then exit doMenu
- put false into firstCopyCardPrompt
- end if
- if firstCopyCardPrompt = false then
- send "doMenu Paste Card" to HyperCard
- beep
- set the cursor to 4
- put "WARNING: Duplicate card names might cause crashes or other problems!!"
- put item 1 of the rect of the msg box into MsgH
- put item 2 of the rect of the msg box into MsgV
- repeat until abs(MsgV - 150) < 5
- if MsgV < 150 then
- add (150 - MsgV) div 5 to MsgV
- else
- subtract (MsgV - 150) div 5 from MsgV
- end if
- if abs(MsgH - 20) > 1 then
- if MsgH < 20 then
- add (20 - MsgH) div 2 to MsgH
- else
- subtract (MsgH - 20) div 2 from MsgH
- end if
- end if
- show msg at MsgH,MsgV
- end repeat
- exit doMenu
- end if
- end if
- pass doMenu
- end doMenu
-
- on findNote
- global scriptMode,note,whichNote
- put "newLine" into scriptMode
- wait until the mouse is down
- put the mouseLoc into mouseDownLoc
- wait until the mouse is up
- put "One moment please…" into line 2 of card field "headerPrompt"
- put the mouseLoc into mouseUpLoc
- put item 1 of mouseDownLoc into Hd
- put item 2 of mouseDownLoc into Vd
- put item 1 of mouseUpLoc into Hu
- put item 2 of mouseUpLoc into Vu
- put item 1 of the rect of card button id 236 into L
- put item 2 of the rect of card button id 236 into T
- put item 3 of the rect of card button id 319 into R
- put item 4 of the rect of card button id 236 into B
- if Hu > L and Hu < R and Vu > T and Vu < B and¬
- Hd > L and Hd < R and Vd > T and Vd < B then
- drag from mouseDownLoc to mouseUpLoc
- put last word of last line of card field "scriptWindow" into note
- delete char 1 of note
- delete last char of note
- delete last char of note
- put whichNote&¬e into line 2 of card field "headerPrompt"
- delete last line of card field "scriptWindow"
- put the id of card button note into buttonID
- if buttonID >235 and buttonID < 320 then
- put buttonID - 212 into note
- else
- beep
- answer "Not a note button"
- put "Not a note button" into note
- end if
- else
- beep
- answer "Not a note button"
- put "Not a note button" into note
- end if
- end fin